var app_module = angular.module('MyApp', ['ngMaterial', 'ngMessages', 'ngMaterialDatePicker']);


app_module.service('communicate', function () {
  this.methodSet = new Map();
  this.register = function (o, method) {
    this.methodSet.set(o, method);
  };

  this.unregister = function (o) {
    this.methodSet.delete(o)
  };

  this.getMethod = function (o) {
    return this.methodSet.get(o)
  };

  this.sendMain = function (name, data) {
    this.getMethod(0).sendData(name, data);
  };
});


app_module.controller('AppCtrl', function ($scope, $timeout, $mdDialog, $mdBottomSheet, $mdToast, $compile, $interval, communicate) {
  $scope.radio = {
    group1: '手机',
  };
  $scope.radio1 = {
    group1: '手机',
  };

  $scope.img = 1;
  $scope.img1 = 1;
//   <md-card md-theme-watch layout-fill>
//   <br><br>对象详细信息<br><br>
//   姓名：白家璇<br><br>
//   身份证号: 411302199802070017<br><br>
//   手机号: 13757988128<br><br>
//   住址: 安徽省合肥市包河区金寨路96号PB2015级00至02学院
// </md-card>
  $scope.idInfos = [
    {
      "name": "白家璇",
      "id": "411302199802070017",
      "phone": "1568655652",
      "address": "安徽省合肥市包河区金寨路96号PB2015级00至02学院"
    },
    {
      "name": "李岁缠",
      "id": "622727199112148613",
      "phone": "18767821242",
      "address": "安徽省合肥市包河区金寨路96号中国科学技术大学SA2015级1至38系"
    },
    {
      "name": "陆长雷",
      "id": "321324199802070017",
      "phone": "1788655652",
      "address": "江苏省泗洪县魏营镇剧名委员会四组41号"
    },
    {
      "name": "廖长涛",
      "id": "3424221998020702345",
      "phone": "1328655652",
      "address": "安徽省寿县双桥镇红楼村名组"
    },
    {
      "name": "宋路川",
      "id": "4113021998020754323",
      "phone": "1368655652",
      "address": "安徽省合肥市蜀山区观亭路19号2栋402室"
    },
    {
      "name": "谭振涛",
      "id": "411302199802070013",
      "phone": "1818655652",
      "address": "杭州市富阳区富春街道迎春路20号606室"
    },
    {
      "name": "阳沁宏",
      "id": "511362399802070042",
      "phone": "1888655652",
      "address": "成都市高新区天顺路66号4栋2单元1303号"
    },
    {
      "name": "杨文强",
      "id": "511302199802243535",
      "phone": "1308655652",
      "address": "四川省武胜县赛马镇七公桥村3组46号"
    },
    {
      "name": "余卓然",
      "id": "342523199912020016",
      "phone": "1568655652",
      "address": "安徽省广德县桃州镇升平街花园西路21号"
    },
    {
      "name": "张佳赋",
      "id": "411302199802072281X",
      "phone": "1878655652",
      "address": "河南省灵宝市含谷镇埤头村4组182号"
    },
    {
      "name": "赵志伟",
      "id": "411302199802070017",
      "phone": "1848655652",
      "address": "安徽省阜南县朱寨镇形状村东对8号"
    },
    {
      "name": "龚涛",
      "id": "411302199802070017",
      "phone": "1658655652",
      "address": "安徽省合肥市包河区金寨路96号PB2012级203至210学院"
    },
    {
      "name": "姬楠",
      "id": "411302199802070017",
      "phone": "1328655652",
      "address": "江苏省邳州市义堂路村姬张10号"
    },
    {
      "name": "金振超",
      "id": "411302199802070017",
      "phone": "1478655652",
      "address": "镇江生金华市金东区董雅芳付村上进巷36号"
    },
    {
      "name": "刘乾坤",
      "id": "411302199802070017",
      "phone": "1828655652",
      "address": "安徽省阜阳市成绩真张庄村赵庄49户"
    },
    {
      "name": "袁皓洁",
      "id": "411302199802070017",
      "phone": "167980252",
      "address": "郑州市管城回族区是巴黎河镇河西袁村141号"
    },
  ];

  $scope.idInfo = $scope.idInfos[0];
  $scope.idInfo1 = $scope.idInfos[0];

  $scope.nextIdCard = function () {
    console.log("net id card")
    $scope.img %= 16;
    $scope.img += 1;
    $scope.idInfo = $scope.idInfos[$scope.img-1];
  };

  $scope.nextIdCard1 = function () {
    console.log("net id card")
    $scope.img1 %= 16;
    $scope.img1 += 1;
    $scope.idInfo1 = $scope.idInfos[$scope.img1-1];

  };

  // Model bound to input fields and modal
  $scope.now = new Date();
  $scope.start = function () {
    //stop();	
    timer = $interval(function () {
      $scope.now = new Date();
    }, 1000);
    $scope.stop = function () {
      $interval.cancel(timer);
    }
  };
  $scope.start();
  // Optional message to display below each input field
  $scope.message = {
    hour: 'Hour is required',
    minute: 'Minute is required',
    meridiem: 'Meridiem is required'
  }

  $scope.readonly = false;

  $scope.required = true;


  $scope.series = ['Series A', 'Series B'];

  $scope.data = [
    [{
      x: 400,
      y: 10,
      r: 20
    }],
    [{
      x: 10,
      y: 40,
      r: 50
    }]
  ];

  $scope.addItem = function (e) {
    console.log(e)
  }

  $scope.area = "北京"
  $scope.showArea = function (ev, t) {
    $mdDialog.show({
      controller: DialogAreaCotroller,
      templateUrl: 'dialog.area.html',
      parent: angular.element(document.body),
      targetEvent: ev,
      clickOutsideToClose: true,
      fullscreen: false // Only for -xs, -sm breakpoints.
    }).then(function (answer) {
      $scope.area = answer;
    }, function () {
      $scope.status = 'You cancelled the dialog.';
    });
  };

  function DialogAreaCotroller($scope, $mdDialog) {
    $scope.hide = function () {
      $mdDialog.hide();
    };

    $scope.cancel = function () {
      $mdDialog.cancel();
    };

    $scope.answer = function (answer) {
      if (answer === "useful") {
        $mdDialog.hide($scope.areas);
      }
      $mdDialog.hide($scope.areas);
    };
    $scope.areas = "北京"
    $scope.area_array = ['北京', '上海', '深圳']
  }

  /*------------------------------------------------------*/

  $scope.start_time = "2020-11-2 13:13"
  $scope.end_time = "2020-11-3 13:13"
  $scope.showAdvanced = function (ev, t) {
    $mdDialog.show({
      controller: DialogController,
      templateUrl: 'dialog1.tmpl.html',
      parent: angular.element(document.body),
      targetEvent: ev,
      clickOutsideToClose: true,
      fullscreen: false // Only for -xs, -sm breakpoints.
    }).then(function (answer) {
      // $scope.status = 'You said the information was "' + answer + '".';
      console.log(t)
      if (t === 'start') {
        $scope.start_time = answer
      } else {
        $scope.end_time = answer
      }
    }, function () {
      // $scope.status = 'You cancelled the dialog.';
    });
  };

  function DialogController($scope, $mdDialog) {
    $scope.hide = function () {
      $mdDialog.hide();
    };

    $scope.cancel = function () {
      $mdDialog.cancel();
    };

    $scope.answer = function (answer) {
      if (answer === "useful") {
        var t = $scope.times[0].select + "-" + $scope.times[1].select + "-" + $scope.times[2].select + " " + $scope.times[3].select + ":" + $scope.times[4].select
        console.log(t);
        $mdDialog.hide(t);
      }

    };


    $scope.month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

    $scope.times = [{
      "name": "年",
      "data": [2016, 2017, 2018, 2019, 2020, 2021],
      "select": 2020
    }, {
      "name": "月",
      "data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
      "select": 11
    }, {
      "name": "日",
      "data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
      "select": 2
    }, {
      "name": "时",
      "data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
      "select": 13
    }, {
      "name": "分",
      "data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59],
      "select": 13
    }, {
      "name": "秒",
      "data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59],
      "select": 14
    }]




  }



});